﻿using com.iot.core.annotation; 
using com.iot.core.data; 
using com.iot.core.manager.auth;
using com.iot.ht.Controllers.htpage.data;
using com.iot.ht.Controllers.htpage.service; 
using Microsoft.AspNetCore.Mvc; 

namespace com.iot.ht.Controllers.htpage
{
    [ApiController]
    [Route("[controller]/[action]")]
    [Tag(Name = "功能菜单", Description = "")]
    public class HtPageController : ControllerBase
    {
        private readonly IHtPageService baseService;
        
        public HtPageController(IHtPageService p1)
        {
            baseService = p1;
        }


        [HttpPost]
        [Operation(Summary = "功能菜单分页", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<Page<HtPageDto>> PageAsync([FromBody] BasePageDtQto mm)
        {
            var r = await baseService.PageAsync(mm);
            return r;
        }


        [HttpPost]
        [Operation(Summary = "功能菜单详情", Description = "")]         
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public async Task<HtPageDto> DetailAsync(BaseQto qm)
        {
            return await baseService.DetailAsync(qm);
        }

        [HttpPost]
        [Operation(Summary = "插入功能菜单初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public HtPageDto InsertInit( )
        {
            return   baseService.InsertInit( );
        }


        [HttpPost]
        [Operation(Summary = "插入页面权限初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = false, LogPout = false, LogTemplete = "")]
        public HtPageDto InsertAuthInit()
        {
            return baseService.InsertInit();
        }



        [HttpPost]
        [Operation(Summary = "添加功能菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Insert(HtPageDto qm)
        {
            return baseService.Insert(qm);
        }

        [HttpPost]
        [Operation(Summary = "修改功能菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Update(HtPageDto qm)
        {
            return baseService.Update(qm);
        }

        [HttpPost]
        [Operation(Summary = "删除功能菜单", Description = "")]
        [Auth(AuthType.Auth)]
        [Log(LogNeed = true, LogPin = true, LogPout = true, LogTemplete = "")]
        public int Delete(BaseQto qm)
        {
            return baseService.Delete(qm);
        }

        [HttpPost]
        [Operation(Summary = "根据ctlid新增功能菜单初始化", Description = "")]
        [Auth(AuthType.Login)]
        [Log(LogNeed = false, LogPin = true, LogPout = true, LogTemplete = "")]
        public HtPageDto InsertInitForCtl(BaseQto qm)
        {
            return baseService.InsertInitForCtl(qm.Id);
        }
    }
}
